package assig2;

import java.util.*;

/** Class for a work of art
 * 
 * @author ciaraldi
 *
 */
public class Art {
	protected Person owner;
	protected Date creationDate;
	protected double value;
	
	/**
	 * @return the owner
	 */
	public Person getOwner() {
		return owner;
	}

	/**
	 * @return the creationDate
	 */
	public Date getCreationDate() {
		return creationDate;
	}

	/**
	 * @param owner the owner to set
	 */
	public void setOwner(Person owner) {
		this.owner = owner;
	}

	/**
	 * @param creationDate the creationDate to set
	 */
	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}
	

	/**
	 * @return the value
	 */
	public double getValue() {
		return value;
	}

	/**
	 * @param value the value to set
	 */
	public void setValue(double value) {
		this.value = value;
	}

	/** Default constructor
	 * 
	 */
	Art() {
		owner = null;
		creationDate = new Date(); // Assume current date and tme
		value = 0;
	}
	
	/**
	 * @param creationDate
	 * @param ownerName 
	 * @param ownerId
	 */
	Art(Date creationDate, String ownerName, long ownerId) {
		owner = new Person(ownerName, ownerId);
		this.creationDate = creationDate;
		this.value = 0;
	}
	
	Art(Date creationDate, String ownerName, long ownerId, double value) {
		owner = new Person(ownerName, ownerId);
		this.creationDate = creationDate;
		this.value = value;
	}
	
	/**
	 * @return String version of the object
	 */
	public String toString() {
		String s = ""; // Return string, gets constructed
		
		// First handle the owner, if any
		if (owner == null) {
			s = "No owner ";
		} else {
			s = "Owner: " + owner + " ";
		}
		
		// Then add the creaton date
		s = s + "Creation date: " + creationDate;
		s =s + " Worth " + value + " dollars";
		return s;
	}
	
	/**
	 * @return volume of the object
	 */
	public double volume() {
		return 0.0;
	}
	
	/**
	 * @param valueAdd increments the existing value by this amount
	 */
	public void addValue(double valueAdd){
		value = value + valueAdd; 
	}
	
	/** Main program for testing Art and its subclasses
	 * @param args
	 */
	public static void main(String[] args) {
		Art a1 = new Art(); // A default Art object
		// An art object with some information
		Art a2 = new Art(new Date(), "Dennis Berkey", 123456789L);
		Art a3;
		
		System.out.println("a1 = " + a1);
		System.out.println("a1's volume = " + a1.volume());
		System.out.println("a2 = " + a2);
		System.out.println("a2's volume = " + a2.volume());
		a3 = a2;
		// Notice how the reference to the object has been copied.
		System.out.println("a3 = " + a3);
		System.out.println("a3's volume = " + a3.volume());
		
		// Now instantiate some drawings
		Drawing d1 = new Drawing();
		Drawing d2 = new Drawing(new Date(), "John Orr", 987654321L,
				10.5, 31.7);
		Drawing d3;
		
		System.out.println("d1 = " + d1);
		System.out.println("d1's volume = " + d1.volume());
		System.out.println("d2 = " + d2);
		System.out.println("d2's volume = " + d2.volume());
		// now try upcasting
		Art a4 = d2;
		System.out.println("a4 = " + a4);
		System.out.println("a4's volume = " + a4.volume());
		
		// instantiate a default sculpture object
		Sculpture s1 = new Sculpture();
		System.out.println("s1 = " + s1);
		System.out.println("s1'volume = " + s1.volume());
		Sculpture s2 = new Sculpture(new Date(), "John Woo", 000000001L,
				  2,3,4);
		System.out.println("s2 = " + s2);
		System.out.println("s2' volume = " + s2.volume());
		
		// test getters
		System.out.println("a2'owner = " + a2.getOwner() + 
					" a2'creation date = " + a2.getCreationDate() );
		System.out.println("d2'owner = " + d2.getOwner() + 
					" d2'creation date = " + d2.getCreationDate() + 
					" d2'height = " + d2.getHeight() + 
					" d2'width = " + d2.getWidth() );
		
		System.out.println("a4'owner = " + a4.getOwner() + 
				" a4'creation date = " + a4.getCreationDate() + 
				" a4'height = " + ((Drawing) a4).getHeight() + 
				" a4'width = " + ((Drawing) a4).getWidth() );
		
		System.out.println("s2'owner = " + s2.getOwner() + 
				" s2'creation date = " + s2.getCreationDate() + 
				" s2'height = " + s2.getHeight() + 
				" s2'width = " + s2.getWidth() + 
				" s2'depth = " + s2.getDepth());
		
		// test for Sketch and Cartoon
		Person artist1 = new Person("Peter", 1L);
		Person artist2 = new Person("David", 2L);
		Person artist3 = new Person("Mike", 3L);
		Sketch sketch1 = new Sketch();
		Sketch sketch2 = new Sketch(new Date(), "John Orr", 987654321L,
				10.5, 31.7,artist1);
		System.out.println("sketch1 = " + sketch1);
		System.out.println("sketch2 = " + sketch2);
		
		Cartoon cartoon1 = new Cartoon();
		Cartoon cartoon2 = new Cartoon(new Date(), "John Woo", 000000001L,
				10.5, 31.7,artist1,artist2,artist3);
		System.out.println("cartoon1 = " + cartoon1);
		System.out.println("cartoon2 = " + cartoon2);
		
		
		//test setters
		System.out.println("a2's orignal owner: " + a2.getOwner());
		a2.setOwner(artist1);
		System.out.println("a2's new owner:" + a2.getOwner());
		
		System.out.println("cartoon2's orignal colorist: " + cartoon2.getColorist());
		cartoon2.setColorist(artist2);
		System.out.println("cartoon2's new owner:" + cartoon2.getColorist());
		
		// test value field
		Art a5 = new Art(new Date(),"Cooper", 314159L, 99.9);
		System.out.println("a5 = " + a5);
		System.out.println("a5's now price is: " + a5.getValue());
		a5.addValue(-20);
		System.out.println("On sale, now a5's price is: " + a5.getValue());
		a5.addValue(40);
		System.out.println("Sale off , now a5's price is: " + a5.getValue());
	}
}
